package com.wangc.commons.configuration;

import com.wangc.commons.dto.Route;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 *   @Author: wangbaojun.
 *   @Description: 生产者：配置rabbitMQ的key和exchange
 *   @Date:Created in 2020/4/28 10:45.
 *   @Modified By:
 *  
 */
@Component
@ConfigurationProperties(prefix = "mq.producer")
public class ProducerMessageQueue {
    List<Route> tasks = new ArrayList<>();

    public List<Route> getTasks() {
        return tasks;
    }

    public void setTasks(List<Route> tasks) {
        this.tasks = tasks;
    }

    public Route getTaskByRouteId(String routeId) {
        return tasks.stream().filter(task -> routeId.equals(task.getRouteId())).findFirst().get();
    }
}
